<?php
	class MY_Upload extends CI_Upload {
    
    function _prep_filename($filename)
    {
        $extension = $this->get_extension($filename);
        $filename = (empty($this->file_name)) ? $filename : $this->file_name.$this->file_ext;
    
        if (strpos($filename, '.') === FALSE)
        {
            return $filename;
        }
        
        $parts        = explode('.', $filename);
        $ext        = array_pop($parts);
        $filename    = array_shift($parts);
                
        foreach ($parts as $part)
        {
            if ($this->mimes_types(strtolower($part)) === FALSE)
            {
                $filename .= '.'.$part;
            }
            else
            {
                $filename .= '.'.$part;
            }
        }
        
        $filename .= '.'.$ext;
        
        return $filename;
    }
}